import Vue from 'vue';
import VueRouter from 'vue-router';
Vue.use(VueRouter);


const _import = require('./_import_' + process.env.NODE_ENV);

const LoginRouter = _import('views/login/login');
// const LoginRouter = _import('components/login');
export const constantRouterMap = [
  {path: '/login', component: LoginRouter, hidden: true},
  {path: '/login1', component: _import('components/login'), hidden: true},
  {path: '/logout', component: _import('views/login/logout'), hidden: true},
  {
    path: '/page', redirect: '/page/404', name: 'Pages',
    //加上这段不触发跳转而是打开子集合
    component: { render(c) { return c('router-view') } },
    children: [
      {path: '404', name: 'Page404', component: _import('views/components/404')},
      {path: '500', name: 'Page500', component: _import('views/components/404')},
    ]
  }
];

const Full = _import('views/Full');
export const asyncRouterMap = [
  {
    path: '/',
    redirect: '/index',
    name: '首页',
    component: Full,
    hidden: false,
    children: [
      {
        name: '数据可视化',
        path: '/dashboard',
        icon: 'iconfont',
        component: _import('views/page/index/dashboard'),
        meta: {role: ['admin', 'operator', 'moc']},
      },
      {
        name: '商品管理',
        path: '/product',
        icon: 'iconfont',
        meta: {},
        //加上这段不触发跳转而是打开子集合
        component: { render(c) { return c('router-view') } },
        children: []
      },
    ]
  },
  {path: '*', redirect: '/page/404', hidden: true}
];

export default new VueRouter({
  // mode: 'history',
  mode: 'hash',
  linkActiveClass: 'open active',
  scrollBehavior: () => ({y: 0}),
  routes: asyncRouterMap.concat(constantRouterMap)
});
